package com.linhui.springbootinit.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.linhui.apicommon.model.entity.User;
import com.linhui.apicommon.service.InnerUserService;
import com.linhui.springbootinit.common.ErrorCode;
import com.linhui.springbootinit.exception.BusinessException;
import com.linhui.springbootinit.mapper.UserMapper;
import com.linhui.springbootinit.service.UserInterfaceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author: 临晖
 * @since: 2024-05-06
 */

@DubboService
public class InnerUserServiceImpl implements InnerUserService {



    @Resource
    private UserMapper userMapper;

    /**
     *
     * 获取用户调用信息
     *
     * @param accessKey
     * @return
     */
    @Override
    public User getInvokeUser(String accessKey) {

        if (StringUtils.isBlank(accessKey)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("accessKey", accessKey);
        User user = userMapper.selectOne(queryWrapper);
        return user;
    }
}
